home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / text / misc / port / string / strncmp.s < prev    next >
Encoding:
Text File  |  1996-09-07  |  437 b   |  33 lines

  1.  
  2.     XDEF    StrNCmp
  3.  
  4. ; StrNCmp() - Compares two strings in A0 and A1 for D0 bytes.
  5.  
  6. ; Result:
  7. ; D0 = 0 if they are equal, non-zero if not.
  8.  
  9. StrNCmp:
  10.     subq.l    #1,d0
  11.     bpl.b    .Cont
  12.     moveq    #0,d0            ; Were equal until here, return 0.
  13.     rts
  14.  
  15. .Cont:
  16.     cmpm.b    (a0)+,(a1)+
  17.     beq.b    .NullCheck
  18.     bra.b    .NotEqual
  19.     
  20. .NullCheck:
  21.     tst.b    (a0)
  22.     bne.b    StrNCmp
  23.     tst.b    (a0)
  24.     bne.b    .NotEqual
  25.     tst.b    (a1)
  26.     bne.b    .NotEqual
  27.     moveq    #0,d0
  28.     rts
  29.  
  30. .NotEqual:
  31.     moveq    #-1,d0
  32.     rts
  33.